import 'package:flutter/material.dart';
import 'package:aweb5/base/BaseWidget.dart';
import 'package:aweb5/util/HttpClient.dart';
class OrderDetail extends BaseWidget {
  @override
  State<OrderDetail> createState() => OrderDetailState();
}

class OrderDetailState extends BaseWidgetState<OrderDetail> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: appBarWithBack("订单详情"),
      body: Column(
        children: <Widget>[
          top(),
          Expanded(
            child: CustomScrollView(
              slivers: <Widget>[
                SliverToBoxAdapter(
                  child: listTitle(),
                ),
                SliverList(
                  delegate: SliverChildBuilderDelegate((con, ind) {
                    return listItem(ind);
                  }, childCount: 5),
                ),
                SliverToBoxAdapter(
                  child: bottom(),
                )
              ],
            ),
          ),

        ],
      ),
    );
  }

  Widget top() {
    return Stack(
      children: <Widget>[
        Column(
          children: <Widget>[
            Container(
              height: 88,
              padding: EdgeInsets.only(left: 15, top: 20),
              decoration: BoxDecoration(
                  image: DecorationImage(
                      image: AssetImage("assets/daifukuan_bg.png"),fit: BoxFit.fill)),
            ),
            Container(
              height: 80,
              color: Colors.white,
            )
          ],
        ),
        Positioned(
            top: 50,
            left: 12,
            right: 12,
            child: Card(
              elevation: 5,
              child: Container(
                height: 100,
                padding:
                    EdgeInsets.only(left: 25, right: 10, top: 20, bottom: 20),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(20),
                ),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Image.asset(
                      "assets/dizhi1.png",
                      width: 10,
                      height: 15,
                    ),
                    SizedBox(
                      width: 10,
                    ),
                    Expanded(
                        child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Row(
                          children: <Widget>[
                            Text(
                              "收货人：刘某某",
                              style: TextStyle(
                                  color: Color(0xff2d2d2d), fontSize: 12),
                            ),
                            SizedBox(
                              width: 10,
                            ),
                            Text("18787876780",
                                style: TextStyle(
                                    color: Color(0xff2d2d2d), fontSize: 12))
                          ],
                        ),
                        SizedBox(
                          height: 5,
                        ),
                        Text(
                          "收货地址：河北省保定市莲池区西下关街000号 ",
                          style:
                              TextStyle(color: Color(0xff464646), fontSize: 12),
                          maxLines: 2,
                          overflow: TextOverflow.ellipsis,
                        )
                      ],
                    ))
                  ],
                ),
              ),
            )),
        Positioned(
          left: 15,
          top: 20,
          child: Text(
            "待收货",
            style: TextStyle(color: Colors.white, fontSize: 18),
          ),
        )
      ],
    );
  }

  Widget listTitle() {
    return Container(
      height: 30,
      margin: EdgeInsets.only(left: 10, right: 10),
      child: Row(
        children: <Widget>[
          Image.asset(
            "assets/ab.png",
            width: 15,
            height: 13,
          ),
          SizedBox(
            width: 3,
          ),
          Text(
            "KIDWRAP",
            style: TextStyle(color: Color(0xff4b4b4b), fontSize: 12),
          ),
          Expanded(child: Text("")),
          Text("共3件商品",
              style: TextStyle(color: Color(0xff4b4b4b), fontSize: 12))
        ],
      ),
    );

    ;
  }

  Widget listItem(ind) {
    return Column(
      children: <Widget>[
        InkWell(
          child: Container(
            margin: EdgeInsets.only(left: 0, right: 0),
            height: 100,
            color: Colors.white,
            padding: EdgeInsets.only(left: 10, right: 10, top: 10),
            child: Row(
              children: <Widget>[
                Image.asset(
                  "assets/banner1.png",
                  width: 80,
                  height: 80,
                  fit: BoxFit.fill,
                ),
                SizedBox(
                  width: 10,
                ),
                Expanded(
                  child: Column(
                    //crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text(
                        "好喝的牛奶111111111111111111111111111111111111111111111",
                        style: TextStyle(color: Colors.black, fontSize: 14),
                        overflow: TextOverflow.ellipsis,
                        maxLines: 2,
                      ),
                      Expanded(child: Text("")),
                      Row(
                        children: <Widget>[
                          Column(
                            children: <Widget>[
                              Text(
                                "规格",
                                style: TextStyle(
                                    fontSize: 9, color: Color(0xff888888)),
                              ),
                              Text(
                                "1",
                                style: TextStyle(
                                    color: Color(0xffff0036), fontSize: 16),
                              )
                            ],
                          ),
                          Expanded(child: Text("")),
                          Text(
                            "x2",
                            style: TextStyle(
                                color: Color(0xff2d2d2d), fontSize: 13),
                          )
                        ],
                      )
                    ],
                  ),
                ),
              ],
            ),
          ),
          onTap: () {
            navigatorState.push(new MaterialPageRoute(builder: (c) {
              return OrderDetail();
            }));
          },
        ),
        Divider(
          height: 1,
          color: Color(0xffe9e9e9),
        )
      ],
    );
  }

  Widget bottom() {
    return Column(
      children: <Widget>[

        Container(height: 10,color: Color(0xfff4f4f4),),
        Container(
          height: 35,
          alignment: Alignment.centerLeft,
          margin: EdgeInsets.only(left: 12, top: 12),
          child: Text(
            "订单备注",
            style: TextStyle(color: Color(0xff2d2d2d), fontSize: 13),
          ),
        ),
        Divider(
          height: 1,
          color: Color(0xffe9e9e9),
        ),
        Container(
          padding: EdgeInsets.all(12),
          child: Text(
            "备注信息内容备注信息内容备注信息内容备注信息内容备注信息内容(当没有备注信息时显示“无”）",
            style: TextStyle(color: Color(0xff2d2d2d), fontSize: 12),
          ),
        ),
        Container(height: 10,color: Color(0xfff4f4f4),),
        Container(
          height: 35,
          alignment: Alignment.centerLeft,
          margin: EdgeInsets.only(left: 12, top: 12),
          child: Text(
            "订单信息",
            style: TextStyle(color: Color(0xff2d2d2d), fontSize: 13),
          ),
        ),
        Divider(
          height: 1,
          color: Color(0xffe9e9e9),
        ),
        Container(
          alignment: Alignment.centerLeft,
          padding: EdgeInsets.all(12),
          child:Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[

                Text("订单编号：9090000909889",style: TextStyle(color: Color(0xff2d2d2d), fontSize: 12)),
                Text("下单时间：2018-05-20 14:12:19",style: TextStyle(color: Color(0xff2d2d2d), fontSize: 12)),
                Text("支付方式：微信支付",style: TextStyle(color: Color(0xff2d2d2d), fontSize: 12))

            ],
          ),

        ),
        Container(height: 10,color: Color(0xfff4f4f4),),
        Container(
          height: 35,
          alignment: Alignment.centerLeft,
          margin: EdgeInsets.only(left: 12, top: 12),
          child: Text(
            "结算金额",
            style: TextStyle(color: Color(0xff2d2d2d), fontSize: 13),
          ),
        ),
        Divider(
          height: 1,
          color: Color(0xffe9e9e9),
        ),
        Container(
          padding: EdgeInsets.all(12),
          child:Column(
            children: <Widget>[
              Row(children: <Widget>[
                Text("商品金额",style: TextStyle(color: Color(0xff2d2d2d), fontSize: 12)),
                Expanded(child: Text("")),
                Text("¥766"),


              ],),
              Row(children: <Widget>[
                Text("商品运费",style: TextStyle(color: Color(0xff2d2d2d), fontSize: 12)),
                Expanded(child: Text("")),
                Text("¥766"),


              ],),
              Row(children: <Widget>[
                Text("优惠券抵扣",style: TextStyle(color: Color(0xff2d2d2d), fontSize: 12)),
                Expanded(child: Text("")),
                Text("¥766"),


              ],),
            ],
          ),

        ),
        Divider(
          height: 1,
          color: Color(0xffe9e9e9),
        ),
        Container(height:40,margin: EdgeInsets.only(left: 12,right: 12),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
          Text("合计",style: TextStyle(color: Color(0xff2d2d2d),fontSize: 13),),
          Text("¥9",style: TextStyle(color: Color(0xffff0000),fontSize: 16),),

        ],),),
        Container(height: 10,color: Color(0xfff4f4f4),),
        Container(
          alignment: Alignment.centerLeft,
          padding: EdgeInsets.only(left: 10, right: 10),
          color: Colors.white,
          height: 45,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: <Widget>[
              InkWell(
                child: Container(
                  decoration: BoxDecoration(
                      border: Border.all(color: Color(0xffb7b7b7)),
                      borderRadius: BorderRadius.circular(5)),
                  padding:
                  EdgeInsets.only(left: 15, right: 15, top: 2, bottom: 2),
                  child: Text(
                    "查看物流",
                    style: TextStyle(fontSize: 12, color: Color(0xffb7b7b7)),
                  ),
                ),
              ),
              SizedBox(
                width: 10,
              ),
              InkWell(
                child: Container(
                  decoration: BoxDecoration(
                      border: Border.all(color: Color(0xfffe5000)),
                      borderRadius: BorderRadius.circular(5)),
                  padding:
                  EdgeInsets.only(left: 15, right: 15, top: 2, bottom: 2),
                  child: Text(
                    "确认收货",
                    style: TextStyle(fontSize: 12, color: Color(0xfffe5000)),
                  ),
                ),
              )
            ],
          ),
        )
      ],
    );
  }
}
